<%@ include file="connect.jsp" %>

<%
    String learnid = request.getParameter("learn");
    String kata = request.getParameter("word");
    String arti = request.getParameter("arti");
    String jeniskata = request.getParameter("tipeword");
    String contoh = request.getParameter("contoh");
    String images = request.getParameter("image");
    String wordstem = request.getParameter("wordstem");
    String ganti = arti.replaceAll("'", "''");
    String ganticontoh = contoh.replaceAll("'", "''");



    ResultSet rs = stat.executeQuery("select * from Learn where learnid ='" + learnid + "' and paragraph like '%" + kata + "%'");
    if (rs.next()) {
        stat.executeUpdate("Insert into detailLearn (Learnid,words,definition,images,example,partofspeech,wordstem) values ('" + learnid + "','" + kata + "','" + ganti + "','" + images + "','"
                + ganticontoh + "','" + jeniskata + "','" + wordstem + "')");
        response.sendRedirect("EditLearn.jsp?respon=Successfully updated word&id=" + learnid);
    } else {
        response.sendRedirect("EditLearn.jsp?respon=Error! Please input the word that shown in the paragraph!&id=" + learnid);
    }

    conn.close();
%>